#include "mainwindow.h"
#include "ui_mainwindow.h"
#include  "QPainter"
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}
void MainWindow::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QPen pen;//画笔

    pen.setColor(QColor(0,255,0));//给画笔颜色,红绿蓝

    QBrush brush(QColor(255,0,0,125));//给画刷设置颜色

    painter.setPen(pen);//画笔

    painter.setBrush(brush);//画刷

    painter.drawRect(50,50,500,500);//绘制矩形,起点坐标，宽高

    }




